# -*- coding: utf-8 -*-
# encoding:utf-8

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

import redis

red_queue = "the_test_the_url_queue"
red_crawled_set = "the_test_url_has_crawled"

# connect to redis server
try:
	red = redis.Redis(host='localhost', port=6379, db=1)
	red2 = redis.Redis(host='localhost', port=6379, db=2)
except Exception,e:
	print str(e)


def main():
	mem = red.smembers(red_crawled_set)
	for i in mem:
		red2.sadd(red_crawled_set,i)
		red2.lpush(red_queue,i)

def find():
	length = red.llen(red_queue)
	for i in range(0,length):
		if red.lindex(red_queue,i)=="http://www.zhihu.com/people/chen-lin-20-40":
			print i

if __name__ == '__main__':
	main()

